package fr.utbm.gl52.smartgrid.model.sources;

import java.util.Map;
import java.util.TreeMap;

import fr.utbm.gl52.smartgrid.util.properties.Properties;
import fr.utbm.gl52.smartgrid.util.properties.PropertyDouble;

public abstract class NonRenewableSource extends EnergySource {

	private double dynamic;
	private double dynamicMin;
	private double dynamicMax;

	public NonRenewableSource() {
		super();
	}

	public NonRenewableSource(String name, double power, double current,
			double voltage, double efficiency, double powerMin,
			double powerMax, long lifespan, double dynamic, double dynamicMin,
			double dynamicMax) {
		super(name, power, current, voltage, efficiency, powerMin, powerMax,
				lifespan);
		// TODO Auto-generated constructor stub
		this.dynamic = dynamic;
		this.dynamicMax = dynamicMax;
		this.dynamicMin = dynamicMin;
	}

	public double getDynamic() {
		return this.dynamic;
	}

	public void setDynamic(double dynamic) {
		this.dynamic = dynamic;
	}

	public double getDynamicMin() {
		return this.dynamicMin;
	}

	public void setDynamicMin(double dynamicMin) {
		this.dynamicMin = dynamicMin;
	}

	public double getDynamicMax() {
		return this.dynamicMax;
	}

	public void setDynamicMax(double dynamicMax) {
		this.dynamicMax = dynamicMax;
	}

	public Map<String, Properties<?>> getProperties() {
		TreeMap<String, Properties<?>> prop = (TreeMap<String, Properties<?>>) super
				.getProperties();
		PropertyDouble p1 = new PropertyDouble(
				Messages.getString("NonRenewableSource.0"), this.dynamic, false); //$NON-NLS-1$
		PropertyDouble p2 = new PropertyDouble(
				Messages.getString("NonRenewableSource.1"), this.dynamicMin, false); //$NON-NLS-1$
		PropertyDouble p3 = new PropertyDouble(
				Messages.getString("NonRenewableSource.2"), this.dynamicMax, false); //$NON-NLS-1$
		prop.put(p1.getName(), p1);
		prop.put(p2.getName(), p2);
		prop.put(p3.getName(), p3);
		return prop;
	}

	public void setProperties(Map<String, Properties<?>> map) {
		this.dynamic = (Double) map.remove(
				Messages.getString("NonRenewableSource.0")).getValue(); //$NON-NLS-1$
		this.dynamicMin = (Double) map.remove(
				Messages.getString("NonRenewableSource.1")).getValue(); //$NON-NLS-1$
		this.dynamicMax = (Double) map.remove(
				Messages.getString("NonRenewableSource.2")).getValue(); //$NON-NLS-1$
		super.setProperties(map);
	}
}
